package com.sanalkitaplik.hibernateutil;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

public class BooksUtil {
	
	private static Session session = null;
	
	public static Arraylist<String> getBooks(){
		try{
			session = SessionFactoryBuilder.getSessionFactory().openSession(); 
			
			Query query = session.createSQLQuery("select AUTHORIZATION_NAME from SNLKTPLK_ADMIN_AUTHORIZATIONS");
			
			List list = query.list();
			
			for (Iterator iterator = list.iterator(); iterator.hasNext();) {
				authorizationList.add((String) iterator.next());
			}
			
		}
		catch(Exception ex){
			System.err.println("An exception occured while getting books : " +ex.getMessage());
		}
		finally{
			session.flush();
			session.close();
		}
	}

}
